﻿<cfsilent>
	<cfscript>
		
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		propAdvice = getProperty("serviceFactory").getBean("studentPropertyAdvice");
		
		event.setArg("pageTitle", "学费缴费情况");

		currentTab = event.getArg("TabID", "labImport");

		passArgs = structNew();
		
		/* 欠费学生名单 */
		
		sql = "SELECT 
					a.stu_id, 
					a.stu_name, 
					a.stu_sex, 
					d.institute_short, 
					c.sbj_short, 
					b.grade, 
					b.cls_name,
					e.student_prop 
				FROM t_student a 
					 INNER JOIN t_class b ON b.cls_id = a.cls_id 
					 INNER JOIN t_subject c ON c.sbj_id = b.sbj_id 
					 INNER JOIN t_institute  d ON d.institute_id = c.institute_id 
					 INNER JOIN t_student_status e ON e.stu_id = a.stu_id  
				WHERE
					SUBSTR(e.student_prop, 16, 1) = '1' 
					OR  
					SUBSTR(e.student_prop, 17, 1) = '1' 
				ORDER BY 
					d.institute_short,
				  c.sbj_short,
					b.grade,
					a.stu_id";
					
		queryObj = new query( datasource=application.dnsSlave);
		
		rs_student = queryObj.execute( sql=sql ).getResult();
		
		if ( rs_student.recordCount ){
			currentTab = event.getArg("TabID", "labStudentDebt");
		}
											
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('DEFAULT_EVENT')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">学籍信息管理</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 card"></i>学费缴费情况
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="create">
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labStudentDebt">class="active"</cfif> id="labStudentDebt" tabTarget="StudentDebt">欠费学生名单</span>
						<span <cfif currentTab eq "labImport">class="active"</cfif> id="labImport" tabTarget="Import">导入欠费学生名单</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
					});
					
					// -->
					//]]>
				</script>

				<div id="StudentDebt" class="tabContent">
					
					<div class="noticeBlock">
						<h3>欠费学生</h3>
						<p><span class="img icon16x16 message"></span>以下是系统中记录的欠费学生的清单, 若该学生家庭贫困或申请助学贷款, 请勾选贫困生绿色通道</p>
						<hr/>
					</div>
				
					<cfif rs_student.recordCount>
						
							<cfset row = 0 />
							<table class="UIEditable" id="studentList">
								<thead>
									<tr>
										<td width="18"></td>
										<td>学号</td>
										<td>姓名</td>
										<td>性别</td>
										<td>班级</td>
										<td>学院</td>
										<td>专业</td>
										<td width="60">年级</td>
										<td width="40">欠学费</td>
										<td width="40">贫困生</td>
									</tr>
								</thead>
								<tbody>
                                    <cfloop query="rs_student" >
									
										<cfset row ++ />
										<cfset propAdvice.parseProperty( rs_student.student_prop ) />
									
										<tr class="editRows" rowid="<cfoutput>#rs_student.stu_id#</cfoutput>">
											<td class="index"><cfoutput>#row#</cfoutput></td>
											<td><span class="numeric"><cfoutput>#rs_student.stu_id#</cfoutput></span></td>
											<td><cfoutput>#rs_student.stu_name#</cfoutput></td>
											<td><cfoutput>#dictAdvice.getGender( rs_student.stu_sex )#</cfoutput></td>
											<td><cfoutput>#rs_student.cls_name#</cfoutput></td>
											<td><cfoutput>#rs_student.institute_short#</cfoutput></td>
											<td><cfoutput>#rs_student.sbj_short#</cfoutput></td>
											<td><span class="numeric"><cfoutput>#rs_student.grade#</cfoutput></span></td>
											<td><a usage="Debt" rowid="<cfoutput>#rs_student.stu_id#</cfoutput>" href="javascript:void(0);" class="stat <cfif propAdvice.getDebt()>yes<cfelse>no</cfif>"></a></td>
											<td><a usage="Poor" rowid="<cfoutput>#rs_student.stu_id#</cfoutput>" href="javascript:void(0);" class="stat <cfif propAdvice.getPoor()>yes<cfelse>no</cfif>"></a></td>
										</tr>
									</cfloop>
								</tbody>
							</table>
							<script language="javascript" type="text/javascript">
								//<![CDATA[
								<!--
								$(document).ready(function() {
									
									$("a[usage]", $("#studentList")).click(function(){
										
										var rowid = $(this).attr("rowid");
										var method = $(this).attr("usage");

										var status = $(this).hasClass("yes");

										var newStatus = true;
								
										var $row = $("tr.editRows[rowid='" + rowid + "']", $("#studentList"));
										
										/* 切换状态数据 */
										if (status) {
											newStatus = false;
										}
										
										/* 发送请求 */
										$(this).removeClass("no").removeClass("yes").addClass("waiting");
										
										$.post(
												"<cfoutput>#buildURL('apiStudentChargesOwedStatus')#</cfoutput>", 
												{
													'stuid' : rowid,
													'prop' : method,
													'status' : newStatus,
													'seed': (new Date()).getTime()
												}, 
												function(data) {
											
													//alert(data);
													result = $.parseJSON(data);
											
													$(this).removeClass("waiting");
										
													if (result.Debt) { $("a[usage='Debt']", $row).removeClass("no").addClass("yes"); } else { $("a[usage='Debt']", $row).removeClass("yes").addClass("no"); }
													if (result.Poor) { $("a[usage='Poor']", $row).removeClass("no").addClass("yes"); } else { $("a[usage='Poor']", $row).removeClass("yes").addClass("no"); }
												
												});		

									});
									
								});
								// -->
								//]]>
							</script>
							
						<cfelse>
							<div class="systemNotice">
								<p>没有欠费学生数据</p>
							</div>
					</cfif>
				</div>
				
				<div id="Import" class="tabContent">
					
					<div class="noticeBlock">
						<h3>导入欠费学生数据</h3>
						<p><span class="img icon16x16 message"></span>请严格按照如下的数据模板在电子表格文件中录入欠费学生数据. 点击<a href="<cfoutput>#buildURL('importStudentChargesOwedTemplate')#</cfoutput>">下载欠费学生录入模板</a>, 在录入信息时请勿更改第一行表头内容.</p>
						<hr/>
						<table>
							<tr>										
								<td>学号</td><td>姓名</td><td>欠费状态</td>
							</tr>
							<tr>
								<td>20080914</td><td>张三</td><td>欠费 / 已缴清</td>
							</tr>
						</table>
						<hr/>
					</div>
					
					<form target="output" onSubmit="javascript:return processVerfiyForm('formImport');" id="formImport" class="formWrapper" method="post" enctype="multipart/form-data" action="<cfoutput>#buildURL('importStudentChargesOwedDo')#</cfoutput>">
						
						<div class="label">
							<span class="req">*</span><b>导入数据文件</b>
							<input name="upload" id="upload" type="file" verification="required" />
						</div>
						
						<div class="lable"><input id="importTrigger" class="button" type="submit" value="导入欠费学生数据" /></div>
					</form>
					
					<script language="javascript" type="text/javascript">
						//<![CDATA[
						<!--
						$(document).ready(function() {
							$("#importTrigger").click(function(){
								$("#output").attr("src","about:blank").removeClass("hidden_elem");
							});
						});
						// -->
						//]]>
					</script>
					
					
					<iframe name="output" id="output" class="UIframeBox hidden_elem" src="about:blank" frameborder="0"></iframe>
					
				</div>
				
			</div>
		</li>
	</ul>
</div>